package com.hhd.flow.controller;

import com.hhd.flow.vo.Result;
import com.hhd.flow.vo.ViewActionVo;
import com.hhd.flow.vo.ViewVo;
import com.hhd.flow.utils.CommonUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/view")
public class ViewController {


    @RequestMapping("/loadViews")
    public Result loadViews(String formType) {
        return Result.ok(createViews());
    }

    @RequestMapping("/loadViewActions")
    public Result loadViewActions(String formType) {
        return Result.ok(createViewActions());
    }

    private List<ViewActionVo> createViewActions() {
        List<ViewActionVo> res = CommonUtils.newList();
        for (int i = 0; i < 30; i++) {
            res.add(createViewAction(i));
        }
        return res;
    }

    private ViewActionVo createViewAction(int i) {
        ViewActionVo viewActionVo = new ViewActionVo();
        viewActionVo.setValue("viewAction_" + i);
        viewActionVo.setTitle("视图权限_" + i);
        return viewActionVo;
    }

    private List<ViewVo> createViews() {
        List<ViewVo> res = CommonUtils.newList();
        for (int i = 0; i < 30; i++) {

            res.add(createView(i));
        }
        return res;
    }

    private ViewVo createView(int i) {
        ViewVo viewVo = new ViewVo();

        viewVo.setValue("view_" + i);
        viewVo.setTitle("测试视图_" + i);
        return viewVo;
    }
}
